//
//  Utils.swift
//  OSCChina
//
//  Created by 刘威 on 2016/12/1.
//  Copyright © 2016年 刘威. All rights reserved.
//

import Foundation
import Mustache

final public class Utils {
    
    public class func HTMLRenderWithData(data:AnyObject,templateName:String) -> String {
        
        //let template = try! Template(named: "news")
        let templatePath = Bundle.main.path(forResource: "news", ofType: "html")
        //let template = Template(path: "/path/document.html")
        let template = try! Template(path: templatePath!, encoding: String.Encoding.utf8)

        //let template = try! Template(path: "html/article.html")
        // The repository of Bash templates, with extension ".sh":
        //let repo = TemplateRepository(bundle: Bundle.main, templateExtension: "html")
        
        // Disable HTML escaping for Bash scripts:
        //repo.configuration.contentType = .text
        
        // Load the "script.sh" resource:
        //let template = try! repo.template(named: templateName)
        
        return try! template.render(data);
     }

}
